<template>
<div class="menuItemContent">
    <div class="menuItemMainBox">
        <div class="menuItemMainBoxItem" v-for="(item, index) in menuItemDataList" :key="item.id" @click="goMenuItemData(item)">
            <div class="menuItemMainBoxItemLeft">
                <div class="menuItemMainBoxItemLeftIcon">
                    <SvgIcon width="40px" height="40px" :name="item.icon" color="#f5c3cb"></SvgIcon>
                </div>
                <div class="menuItemMainBoxItemLeftTitle">
                    <span class="menuItemMainBoxItemLeftTitle1">{{ item.title }}</span>
                    <span class="menuItemMainBoxItemLeftTitle2">{{ item.text }}</span>
                </div>
            </div>
            <div class="menuItemMainBoxItemRight">
                <van-icon name="arrow"size="20" />
            </div>
        </div>
    </div>
</div>
</template>

<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { showToast, showFailToast } from 'vant'
// import {  } from '@/utils/plugins'
import menuStore from '@/store/modules/menuDataList'
const menuStoreList = menuStore()


const route = useRoute()
const router = useRouter()

const menuItemDataList = ref<any>([])

const goMenuItemData = (item: any) => {
    if (item.path == '') {
        showToast('功能开发中，敬请期待！')
    }
    router.push({
        path: item.path,
        query: {
            // title: item.title
        }
    })
}

onMounted(() => {
    // (window as any).showGlobalLoading()
    console.log('工具列表：', menuStoreList.menuItemDataList)
    if (menuStoreList.menuItemDataList && menuStoreList.menuItemDataList.length > 0) {
        menuItemDataList.value = menuStoreList.menuItemDataList
    } else {
        showFailToast('数据加载失败，请稍后再试！')
        router.back()
    }
})

</script>


<style lang="scss" scoped>
.menuItemContent {
    width: 100%;
    padding: 15px;
    .menuItemMainBox {
        width: 100%;
        padding: 0 5px;
        .menuItemMainBoxItem {
            width: 100%;
            height: 70px;
            background-color: var(--background);
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            border-bottom: 0.5px solid #eee;
            .menuItemMainBoxItemLeft {
                height: 100%;
                display: flex;
                flex-direction: row;
                align-items: center;
                .menuItemMainBoxItemLeftIcon {
                    margin-right: 20px;
                }
                .menuItemMainBoxItemLeftTitle {
                    height: 100%;
                    display: flex;
                    flex-direction: column;
                    justify-content: space-around;
                    .menuItemMainBoxItemLeftTitle1 {
                        margin-top: 10px;
                        font-size: 14px;
                        font-weight: 500;
                    }
                    .menuItemMainBoxItemLeftTitle2 {
                        font-size: 12px;
                        color: rgb(128, 128, 128);
                        margin-bottom: 10px;
                    }
                }
            }
            .menuItemMainBoxItemRight {
                
            }
        }
    }
}
</style>